$(document).ready(function(){

    $("#login_btn").click(function(){
        var loginname = $.trim($("#loginname").val());
        var loginpassword = $.trim($("#loginpassword").val());
        if(loginname == ""){
            alert("请输入登录名");
            return false;
        }else if(loginpassword == ""){
            alert("请输入密码");
            return false;
        }
        //ajax去服务器端校验
        $.ajax({
            url :   "user/mobile/login",
            type:   "post",
            data:JSON.stringify({
                loginName : loginname,
                loginPassword  : loginpassword,
            }),
            beforeSend: function(request) {
                request.setRequestHeader("token", "eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiIxIiwiaWF0IjoxNTMyNDA4ODMzLCJzdWIiOiIxLHd6eSwwIiwiZXhwIjoxNTMyNDE2MDMzfQ.DEpHIrk2X8U4Un_SdDNiqqPPEYHXX6DYfx_prQ3QIZQ");
            },
            contentType:"application/json;",
            success:function(data) {
                console.log(data);
                if(data.code==0){
                    location.href = prefixUrl + "index.html";
                }else{
                    alert("登户名或者密码不正确");
                }
            }
        });
    });
});